//
//  DawnRoot.swift
//  DawnFoundation
//
//  Created by 崔成成 on 2021/8/15.
//

import UIKit
import IQKeyboardManagerSwift
class DawnRoot {
    
    static let shared = DawnRoot()
    private init() {}
    var keyWindow: UIWindow?
    
    func root(to vc: UIViewController) {
        keyWindow?.rootViewController = vc
    }
    
    func root(to type: UIViewController.Type) {
        let vc = type.init()
        keyWindow?.rootViewController = vc
    }
    
    func rootNav(to type: UIViewController.Type) {
        let vc = type.init()
        let nav = UINavigationController(rootViewController: vc)
        keyWindow?.rootViewController = nav
    }

    func rootToWelcome() {
//        let vc = WelcomeVC()
//        vc.callback = { [weak self] in
//            self?.rootNav(to: ViewController.self)
//        }
//        keyWindow?.rootViewController = vc
    }
    
    func rootToMain(index: Int? = nil) {
        let tc = ICTabBarController()
        tc.currentIndex = index
        keyWindow?.rootViewController = tc
        keyWindow?.makeKeyAndVisible()
        
    }
    
    func initialized() {
        IQKeyboardManager.shared.enable = true
        
        rootToMain()
    
    }
    
}
